const { wyy_request } = require("../../../util/wyy_request");
const APIError = require("../../../middlewares/rest").APIError;

// 排行榜歌单详情
let top = async (ctx) => {
    if (ctx.request.method === 'GET') {
        var pid = ctx.request.query.topId || '';
        // console.log(typeof ctx.request.query.limit, limit);
    } else if (ctx.request.method === 'POST') {
        var pid = ctx.request.body.topId || '';
    }

    if (pid.length === 0) {
        throw new APIError("wyy_playlist", "pid not found");
    }

    let result = await wyy_request(`https://music.163.com/api/v6/playlist/detail`, {
        id: pid,
        n: 100000,
        s: 8,
    });

    ctx.rest(result.data);
}


// 排行榜分类
let topCategory = async (ctx) => {
    let result = await wyy_request('https://music.163.com/api/toplist');

    ctx.rest(result.data);
}

module.exports = {
    top,
    topCategory
}